package org.zsl.ssm.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;
import org.zsl.ssm.model.User;

import java.io.IOException;
import java.util.List;


/**
 *   常用数据库操作
 *      和业务逻辑无关 ‘
 *
 *   例如：
 *      crud + exists
 * */
@Mapper
public interface UserMapper {


    @Select("select * from user")
    @Results({
            @Result(column = "user_id",property = "userId"
                    ,jdbcType = JdbcType.INTEGER,id = true),
            @Result(column = "username",property = "username",jdbcType = JdbcType.VARCHAR),
            @Result(column = "password",property = "password",jdbcType = JdbcType.VARCHAR)
    })
    List<User> selectAll() throws IOException;


    int exists(User user);
}
